<?xml version='1.0' encoding='UTF-8' ?> 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:p="http://primefaces.prime.com.tr/ui">

    <h:head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
        <link href="./../resources/css/default.css" rel="stylesheet" type="text/css" />
        <link href="./../resources/css/cssLayout.css" rel="stylesheet" type="text/css" />
        <title>Facelets Template</title>
    </h:head>

    <h:body>

        <div id="top">
            <ui:insert name="top">
            </ui:insert>
        </div>
        <div>
            <div id="left">
                <ui:insert name="left">
                    <h:form>
                        <table>
                            <tr>
                                <td>
                                    <h:commandButton action="welcome" value="Home Page"/>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    <h:commandButton action="search" value="Search for User"/>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    <h:commandButton action="editprofile" value="Edit Profile"/>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    <h:commandButton action="friendspage" value="List Friends"/>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    <h:commandButton action="sendprivatemessage" value="Send Message"/>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    <h:commandButton action="viewprivatemessages" value="View Messages"/>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    <h:commandButton value="#{LoginBean.isLoggedIn()}" action="#{LoginBean.logInOrOut()}"></h:commandButton>
                                </td>
                            </tr>
                        </table>
                    </h:form>
                </ui:insert>
            </div>
            <div>
                <div id="right">
                    <ui:insert name="right">
                        <h:form id="chatForm">
                            <p:dataTable value="#{chatBean.newestMessages}" var="c" id="messages" paginator="true" rows="10" paginatorPosition="never" first="#{chatBean.first}">
                                <p:column headerText="Time">
                                    #{c.date}
                                </p:column>
                                <p:column headerText="Person">
                                    #{c.username}
                                </p:column>
                                <p:column headerText="Message" style="width: 300px">
                                    #{c.content}
                                </p:column>
                            </p:dataTable>
                            <p:poll update="messages" interval="1" />
                            <h:inputText value="#{chatBean.message}"/>
                            <h:commandButton action="#{chatBean.addChatMessage}" value="Send" > 
                                <f:ajax execute="@form" render="chatForm"/> 
                            </h:commandButton>
                        </h:form>
                    </ui:insert>
                </div>
                <div id="content" class="right_content">
                    <ui:insert name="content">Content</ui:insert>
                </div>
            </div>
        </div>

    </h:body>

</html>
